package com.b2c.ftysys.dao.impl;

import com.b2c.ftysys.dao.B2cFsyStaffDAO;
import com.b2c.ftysys.dao.DatabaseException;
import com.b2c.ftysys.domain.B2cFsyStaff;
import com.b2c.ftysys.domain.B2cFsyStaffExample;
import com.b2c.ftysys.helper.FontUtils;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

@Repository
public class B2cFsyStaffDAOImpl extends SupportDAO<B2cFsyStaff> implements
		B2cFsyStaffDAO {

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public B2cFsyStaffDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public void save(B2cFsyStaff record) {
		// getSqlMapClientTemplate().insert("b2c_fsy_staff.abatorgenerated_insert",
		// record);
		try {
			if (StringUtils.isEmpty(record.getPinyinName())) {
				record.setPinyinName(FontUtils.stringArrayToString(FontUtils
						.getHeadByString(record.getStaffName())));
			}
			super.save(record, "b2c_fsy_staff.abatorgenerated_insert");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public int updateByPrimaryKey(B2cFsyStaff record) {
		// int rows =
		// getSqlMapClientTemplate().update("b2c_fsy_staff.abatorgenerated_updateByPrimaryKey",
		// record);
		int rows = 0;
		try {
			if (StringUtils.isEmpty(record.getPinyinName())) {
				record.setPinyinName(FontUtils.stringArrayToString(FontUtils
						.getHeadByString(record.getStaffName())));
			}

			rows = update(record,
					"b2c_fsy_staff.abatorgenerated_updateByPrimaryKey");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public int updateByPrimaryKeySelective(B2cFsyStaff record) {
		// int rows =
		// getSqlMapClientTemplate().update("b2c_fsy_staff.abatorgenerated_updateByPrimaryKeySelective",
		// record);
		// return rows;
		int rows = 0;
		try {
			if (StringUtils.isEmpty(record.getPinyinName())) {
				record.setPinyinName(FontUtils.stringArrayToString(FontUtils
						.getHeadByString(record.getStaffName())));
			}

			rows = super
					.update(record,
							"b2c_fsy_staff.abatorgenerated_updateByPrimaryKeySelective");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	@SuppressWarnings("unchecked")
	public List<B2cFsyStaff> selectByExample(B2cFsyStaffExample example) {
		List<B2cFsyStaff> list = new ArrayList<B2cFsyStaff>();
		try {
			list = super.getList(example,
					"b2c_fsy_staff.abatorgenerated_selectByExample");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		// (List<Pdtorder>)
		// getSqlMapClientTemplate().queryForList("pdtorder.abatorgenerated_selectByExample",
		// example);
		return list;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public B2cFsyStaff selectByPrimaryKey(Integer staffId) {
		B2cFsyStaff key = new B2cFsyStaff();
		key.setStaffId(staffId);
		B2cFsyStaff record = null;
		try {
			record = super.queryWithId(key,
					"b2c_fsy_staff.abatorgenerated_selectByPrimaryKey");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		return record;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public int deleteByExample(B2cFsyStaffExample example) {
		// int rows =
		// getSqlMapClientTemplate().delete("b2c_fsy_staff.abatorgenerated_deleteByExample",
		// example);
		// return rows;
		int rows = 0;
		try {
			rows = super.deleteByObject(example,
					"b2c_fsy_staff.abatorgenerated_deleteByExample");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		// getSqlMapClientTemplate().delete("pdtorder.abatorgenerated_deleteByExample",
		// example);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public int deleteByPrimaryKey(Integer staffId) {
		B2cFsyStaff key = new B2cFsyStaff();
		key.setStaffId(staffId);
		// int rows =
		// getSqlMapClientTemplate().delete("b2c_fsy_staff.abatorgenerated_deleteByPrimaryKey",
		// key);
		int rows = 0;
		try {
			rows = super.delete(key,
					"b2c_fsy_staff.abatorgenerated_deleteByPrimaryKey");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		// getSqlMapClientTemplate().delete("pdtorder.abatorgenerated_deleteByPrimaryKey",
		// key);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public int countByExample(B2cFsyStaffExample example) {
		// Integer count = (Integer)
		// getSqlMapClientTemplate().queryForObject("b2c_fsy_staff.abatorgenerated_countByExample",
		// example);
		Integer count = 0;
		try {
			count = super.getCountByObjectForPage(example,
					"b2c_fsy_staff.abatorgenerated_countByExample");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		return count;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public int updateByExampleSelective(B2cFsyStaff record,
			B2cFsyStaffExample example) {
		record.setPinyinName(FontUtils.stringArrayToString(FontUtils
				.getHeadByString(record.getStaffName())));

		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		// int rows =
		// getSqlMapClientTemplate().update("b2c_fsy_staff.abatorgenerated_updateByExampleSelective",
		// parms);
		int rows = 0;
		try {
			rows = super.updateByObject(parms,
					"b2c_fsy_staff.abatorgenerated_updateByExampleSelective");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		// getSqlMapClientTemplate().update("pdtorder.abatorgenerated_updateByExampleSelective",
		// parms);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	public int updateByExample(B2cFsyStaff record, B2cFsyStaffExample example) {
		record.setPinyinName(FontUtils.stringArrayToString(FontUtils
				.getHeadByString(record.getStaffName())));

		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		// int rows =
		// getSqlMapClientTemplate().update("b2c_fsy_staff.abatorgenerated_updateByExample",
		// parms);
		int rows = 0;
		try {
			rows = super.updateByObject(parms,
					"b2c_fsy_staff.abatorgenerated_updateByExample");
		} catch (DatabaseException e) {
			e.printStackTrace();
		}
		// getSqlMapClientTemplate().update("pdtorder.abatorgenerated_updateByExample",
		// parms);
		return rows;
	}

	/**
	 * This class was generated by Abator for iBATIS. This class corresponds to
	 * the database table b2c_fsy_staff
	 * 
	 * @abatorgenerated Tue Aug 03 12:46:56 CST 2010
	 */
	private static class UpdateByExampleParms extends B2cFsyStaffExample {
		private Object record;

		public UpdateByExampleParms(Object record, B2cFsyStaffExample example) {
			super(example);
			this.record = record;
		}

		public Object getRecord() {
			return record;
		}
	}
}